package com.xsomnus.open.imv2.foo.server.handler;

import com.xsomnus.open.imv2.protocol.request.LogoutRequestPacket;
import com.xsomnus.open.imv2.protocol.response.LogoutResponsePacket;
import com.xsomnus.open.imv2.util.SessionUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author @xsomnus666_xiawenye★
 * @since 2019/4/26 0026 10:03
 * 当你发现自己的才华撑不起野心时，就请安静下来学习吧
 */
public class LogoutRequestHandler extends SimpleChannelInboundHandler<LogoutRequestPacket> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, LogoutRequestPacket msg) throws Exception {
        SessionUtil.unbind(ctx.channel());
        LogoutResponsePacket responsePacket = new LogoutResponsePacket();
        responsePacket.setSuccess(true);
        ctx.channel().writeAndFlush(responsePacket);
    }
}
